HPlane = class("HPlane")


--创建飞机，飞机的血量，速度，预设物，发射间隔
function HPlane:ctor(hp, speed, fireRate, tag, prefab)

    --初始化属性
    self.hp = hp;
    self.maxHp = hp;
    self.speed = speed;
    self.fireRate = fireRate == nill and 4 or fireRate;
    self.fireInterval=1/self.fireRate;
    self.fireTime=Time.time;
    --创建飞机
    self.gameObject=newObject(prefab);
    self.transform=self.gameObject.transform;   
    self.gameObject.tag = tag;

    local luaTrigger = self.gameObject:AddComponent(typeof(LuaRigidTrigger));
    luaTrigger:AddHandler(self.OnTriggerEnter2D, self);

    UpdateBeat:Add(self.Update, self);
end

function HPlane:Update()
    self:Move();
    
    self:CheckFire();
end


function HPlane:Move()

end

function HPlane:CheckFire()
    if(Time.time-self.fireTime>self.fireInterval)then
        self.fireTime=Time.time;

        self:Fire();
    end
end

function HPlane:Fire()
    -- self.bullet = Bullet.new(self.firePoint, 10);
end

function HPlane:OnTriggerEnter2D(collider)
       if self.hp <= 0 then
           return;
       end
end


function HPlane:SubHp()
    print(self.hp .. "*****************************************");
    self.hp = self.hp - 1;
    
end

function HPlane:IsDath()
    if self.hp <= 0 then
        UpdateBeat:Remove(self.Update, self);
        destroy(self.gameObject);

        return true;
    end
    return false;
end